﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using nplJobsCommon.Common;
using System.Data;


namespace nplJobsDAL.Select
{
    public class SelectSalaryRange : DataAccessBase
    {
        public SelectSalaryRange()
        {
            StoredProcedureName = StoredProcedure.Name.spSelectSalaryRange.ToString();
        }

        #region GetSalaryRange
        public List<SalaryRange> GetSalaryRange()
        {
            DataBaseHelper dbHelper;
            DataSet dsSalaryRange;

            try
            {
                dbHelper = new DataBaseHelper(StoredProcedureName);
                dsSalaryRange = dbHelper.Run(base.ConnectionString);
                return GetList(dsSalaryRange);
            }
            catch (Exception)
            {

                throw;
            }
        }
        #endregion

        #region GetList
        private List<SalaryRange> GetList(DataSet dsSalaryRange)
        {
            List<SalaryRange> salaryRanges;
            try
            {
                salaryRanges = (from n in dsSalaryRange.Tables[0].AsEnumerable()
                                select new SalaryRange
                                   {
                                       ID = n.Field<int>("ID"),
                                       Range = n.Field<string>("Range")
                                   }).ToList();

                return salaryRanges;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message.ToString());
            }
            finally { }
        }
        #endregion
    }
}
